<template>
    <div>
        <div class="goods-list">
		<!--在网页中，有两种跳转方式  -->
		<!-- 1. 使用a标签 的形式 ，叫做 标签跳转 -->
		<!-- 2. 使用 window.location.href 的形式， 叫做 编程式导航 -->
		
		<!-- 标签导航 -->
            <router-link class="goods-item" :to="'/home/goodsinfo/'+id" tag="div">
                <img src="//cdn.cnbj1.fds.api.mi-img.com/mi-mall/d880ff45a9a3b70527770e01521fc939.jpg?thumb=1&w=250&h=250&f=webp&q=90" alt="">
                <h1 class="title">小米10至尊纪念版</h1>
                <div class="info">
                    <p class="price">
                        <span class="now">￥999</span>
                        <span class="old">￥899</span>
                    </p>
                    <p class="sell">
                        <span>热卖中</span>
                        <span>剩60件</span>
                    </p>
                </div>
            </router-link>
			
			<!-- 编程式导航 -->
            <div class="goods-item" @click="goDtail(id)">
                <img src="//cdn.cnbj1.fds.api.mi-img.com/mi-mall/d880ff45a9a3b70527770e01521fc939.jpg?thumb=1&w=250&h=250&f=webp&q=90" alt="">
                <h1 class="title">小米10至尊纪念版120X超远变焦/120W 秒充科技/120Hz刷新率+240Hz采样率/骁龙865旗舰处理器双模5G</h1>
                <div class="info">
                    <p class="price">
                        <span class="now">￥999</span>
                        <span class="old">￥899</span>
                    </p>
                    <p class="sell">
                        <span>热卖中</span>
                        <span>剩60件</span>
                    </p>
                </div>
            </div>
            <div class="goods-item" @click="goDtail(id)">
                <img src="//cdn.cnbj1.fds.api.mi-img.com/mi-mall/d880ff45a9a3b70527770e01521fc939.jpg?thumb=1&w=250&h=250&f=webp&q=90" alt="">
                <h1 class="title">小米10至尊纪念版</h1>
                <div class="info">
                    <p class="price">
                        <span class="now">￥999</span>
                        <span class="old">￥899</span>
                    </p>
                    <p class="sell">
                        <span>热卖中</span>
                        <span>剩60件</span>
                    </p>
                </div>
            </div>


        </div>
    </div>
</template>

<script>
export default {
    methods: {
		goDtail(id){
			//使用js方式来跳转
			// this.$router.push('/home/goodsinfo/' + id)
			// 2. 传递对象
			this.$router.push({ path: "/home/goodsinfo/" + id })
		}
		// goDtail1(id){
		// 	// 3. 传递命名的路由;name 要在路由中设置
			// this.$router.push({ name: "goodsinfo" ,params: {id} })
		// }
	}
}
</script>

<style scoped>
.goods-list{
    display: flex;
    flex-wrap: wrap;
    /* justify-content: space-around; */
    padding: 7px;
    justify-content: space-between;
}
.goods-item{
    width: 49%;
    border: 1px solid #ccc;
    box-shadow: 0 0 8px #ccc;
    margin: 4px 0;
    padding: 2px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 293px;
}
.goods-item img{
    width: 100%;
}
.title{
    font-size: 14px;
}
.info{
    background-color: #eee;
}
.info p{
    margin: 0;
    padding: 5px;
}
.now{
    color: red;
    font-weight: bold;
    font-size: 16px;
}
.old{
    text-decoration: line-through;
    font-size: 12px;
    margin-left: 10px;
}
.sell{
    display: flex;
    justify-content: space-between;
}
</style>